import { FormSchema } from '@/components/Form';
import { h } from 'vue';
import { MarkDown } from '@/components/Markdown';
import { uploadApi } from '@/api/sys/upload';
const basicOptions: LabelValueOptions = [
  {
    label: '文艺演出',
    value: '1',
  },
  {
    label: '公益电影',
    value: '2',
  },
];
const basicRangeOptions: LabelValueOptions = [
  {
    label: '开放',
    value: '1',
  },
  {
    label: '会员',
    value: '2',
  },
  {
    label: '注册用户',
    value: '3',
  },
];
const basicFloorOptions: LabelValueOptions = [
  {
    label: '一楼',
    value: '1',
  },
  {
    label: '二楼',
    value: '2',
  },
];

export const schemas: FormSchema[] = [
  {
    field: 'number',
    component: 'Input',
    label: '编号',
    defaultValue: 'RT90928172',
    rules: [{ required: false}],
    dynamicDisabled: true,
  },
  {
    field: 'name',
    component: 'Input',
    label: '名称',
    defaultValue: '<<我和我的祖国>>',
    rules: [{ required: true}],
  },
  {
    field: 'f4',
    component: 'Select',
    label: '类型',
    componentProps: {
      options: basicOptions,
    },
    required: true,
  },
  {
    field: 'fieldsc',
    component: 'Upload',
    label: '上传',
    colProps: {
      span: 8,
    },
    rules: [{ required: true, message: '请选择上传文件' }],
    componentProps: {
      api: uploadApi,
    },
  },
  {
    field: '[startDateTime, endDateTime]',
    label: '领票时间',
    component: 'RangePicker',
    componentProps: {
      format: 'YYYY-MM-DD HH:mm:ss',
      placeholder: ['开始日期、时间', '结束日期、时间'],
      showTime: { format: 'HH:mm:ss' },
    },
    rules: [{ required: true}],
  },
  {
    field: 'markdown',
    component: 'Input',
    label: '演出简介',
    defaultValue: '',
    rules: [{ required: true, trigger: 'blur' }],
    render: ({ model, field }) => {
      return h(MarkDown, {
        value: model[field],
        onChange: (value: string) => {
          model[field] = value;
        },
      });
    },
  },
  {
    field: 'limit',
    component: 'Input',
    label: '每人限领',
    defaultValue: '2',
    rules: [{ required: true}],
  },
  {
    field: 'f6',
    component: 'Select',
    label: '领票范围',
    componentProps: {
      options: basicRangeOptions,
    },
    required: true,
  },
  {
    field: 'f7',
    component: 'Select',
    label: '开放区域',
    componentProps: {
      options: basicFloorOptions,
    },
    required: true,
  },
  {
    field: 'f8',
    label: '禁选座位',
    slot: 'f8',
   /*  colProps: {
      span: 8,
    }, */
    dynamicDisabled: ({ values }) => {
      return !!values.field_disabled;
    },
    rules: [{ required: true }],
  },
  {
    field: 'f9',
    component: 'Input',
    label: '领票提醒',
    defaultValue: '入场请出示订票结果，观影期间请全程佩戴口罩。',
    rules: [{ required: false}],
  },
];